package mysql

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/logger"
	"login/src/conf"
)

var DB *gorm.DB

func Init() {
	var err error
	cfg := conf.GetConf().MySQL
	fmt.Print("dsn:", cfg.DSN)
	DB, err = gorm.Open(mysql.Open(cfg.DSN), &gorm.Config{
		SkipDefaultTransaction: true,
		PrepareStmt:            true,
		Logger:                 logger.Default.LogMode(logger.Info),
	})

	fmt.Println("MySqlDB:", DB)
	if err != nil {
		panic(err)
	}
}
